import math

# class NegativeRadiusError(Exception):
#     pass
#
# radius = float(input("请输入原的半径:"))
#
# try:
#     if radius < 0:
#         raise NegativeRadiusError("半径不能为负数")
#     area = math.pi * radius ** 2
#
#     print("圆的面积为:",area)
# except NegativeRadiusError as e:
#     print("输入的半径为负数，错误信息为:",e)

# class NegativeRadiusException(Exception):
#     pass
# radius = float(input("请输入圆的半径:"))
#
# try:
#     if radius < 0:
#         raise NegativeRadiusException("圆的半径不能为负数")
#     area = math.pi * radius ** 2
#     print("圆的面积为:",area)
# except NegativeRadiusException as e:
#     print("输入的半径为负数，错误信息为:",e)

class NegativeRadiusException(Exception):
    pass
try:
    radius = float(input("请输入圆的半径:"))
    if radius < 0:
        raise NegativeRadiusException("圆的半径不能为负数")
    area = math.pi * radius ** 2
    print("圆的面积为:",area)

except NegativeRadiusException as e:
    print("输入的半径为负数，错误信息为:",e)


